package com.rs.service.impl.rs;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.rs.dao.BehavruleMapper;
import com.rs.model.CommonResult;
import com.rs.model.Behavrule;
import com.rs.service.rs.BehavruleService;

@Service
public class BehavruleServiceImpl implements BehavruleService {

	@Autowired
	private BehavruleMapper bhm;

	/*************APP**********/
	/**
	 * 查询行为绩效考核规则
	 */
	@Override
	public CommonResult<List<Behavrule>> behavruleQueryApp() {
		List<Behavrule> list = bhm.selectAll();
		return new CommonResult<List<Behavrule>>(200, "查询成功", list);
	}

	/***************Pc*******/
	/**
	 * pc添加绩效考核规则
	 */
	@Override
	@Transactional
	public CommonResult<String> behavruleAddPc(List<Behavrule> list) {
		for (Behavrule behavrule : list) {
			bhm.insert(behavrule);
		}
		return new CommonResult<String>(200, "添加成功");
	}

	/**
	 * pc修改绩效考核规则
	 */
	@Override
	@Transactional
	public CommonResult<String> behavruleUpdatePc(List<Behavrule> list) {
		for (Behavrule behavrule : list) {
			bhm.behavruleUpdatePc(behavrule);
		}
		return new CommonResult<String>(200, "修改成功");
	}

	/**
	 * pc查询所有的考核规则
	 */
	@Override
	public CommonResult<List<Behavrule>> behavruleQueryPc() {
		List<Behavrule> list = bhm.selectAll();
		return new CommonResult<List<Behavrule>>(200, "查询成功", list);
	}

	/**
	 * pc删除考核规则
	 */
	@Override
	public CommonResult<String> behavruleDelectPc(Behavrule behavrule) {
		bhm.deleteByPrimaryKey(behavrule.getBer_id());
		return new CommonResult<String>(200, "删除成功");
	}

}
